package com.example.demo.initdatabase.impl;

import com.example.demo.initdatabase.InitDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Jack
 * @Title: Spring boot启动执行类
 * @Description: Spring boot启动执行类
 * @date 2018年1月10日22:58:31
 */
@Component
public class StartupRunner implements CommandLineRunner {
    @Autowired
    private InitDataService initDataService;

    private Logger LOGGER = LoggerFactory.getLogger(StartupRunner.class);

    @Override
    public void run(String... strings) throws Exception {
        if (initDataService.checkIsInit()) {
            LOGGER.info("执行初始化数据...");
            initDataService.initData();
        }
    }
}
